package xyz.talentboy.controller.validate;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import xyz.talentboy.common.bean.SignBean;
import xyz.talentboy.common.util.SignUtil;

@RestController
public class SignatureController {

	private static final Logger logger = LoggerFactory.getLogger(SignatureController.class);
	
	@Value("${token}")
	private String token;
	
	@RequestMapping(value = "/signature",method = RequestMethod.GET )
	public String validate(SignBean signBean) {
		logger.info("接入信息" + signBean.toString());
		if (SignUtil.sign(signBean, token)) {
			logger.info("---------验签成功:接入成功---------");
			return signBean.getEchostr();
		} else {
			logger.info("---------验签失败---------");
			return null;
		}
	}
	@RequestMapping("/")
	public String validate(){
		return "hello world";
	}
}
